<template>
	<view>
		<u-subsection activeColor="#f56c6c" :list="Packages" keyName="pkName" :current="index" @change="change">

		</u-subsection>

		<view v-for="(r,index) in PackagesList" :key="index">
			<uni-card style="padding: 0px;" :is-shadow="false" @click="Totijian(r)">
				<view style="float: left;width: 70px;height: 70px;margin-bottom: 10px;border-radius: 20px;">
					<image style="height: 70px;width: 70px;margin-right: 10px;" :src="r.img">
					</image>
				</view>
				<view style="float: left;width: 170px;height: 120px;margin-left: 10px;">
					<p style="font-size: 16px;margin-bottom: 7px;margin-top: 5px;">{{r.setMealName}}</p>
					<p>项目：{{r.project}}</p>
				</view>
				<view style="float: left;">
					<p style="font-size: 16px;color: #F46363;margin-left: 5px;padding-top: 35px;">￥{{r.price}}</p>
				</view>
			</uni-card>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userId: 1,
				Packages: [],
				index: '',
				packageId: '',
				PackagesList:[],
				p:{},
			}
		},
		onLoad() {

			//查询所有套餐类型
			this.getPackages();
			if (this.packageId == '') {
				this.packageId = 1
			}
			//根据套餐id 查询套餐
			this.getPackagesList();
		},
		methods: {
			Totijian(r){
				console.log(r)
				this.p = r
				//套餐类型Id
				uni.setStorage({
					key: 'packageId',
					data: this.packageId,
					success() {
						console.log('套餐类型id存储成功')
					}
				})
				
				
				//套餐存储
				uni.setStorage({
					key: 'taocan',
					data: this.p,
					success() {
						console.log('套餐存储成功')
					}
				})
				console.log(this.p)
				
				setTimeout(() => {
					uni.navigateTo({
						url: '../zqw/Tijian'
					})
				})
				
			},
			getPackagesList() {

				this.$axios.get("/other/other/package-ype/getPackagesList/" + this.packageId).then((
						res) => {
						console.log("成功")
						this.PackagesList = res.data.data.list
					})
					.catch((error) => {
						console.log(error);
					});

			},
			getPackages() {
				this.$axios.get("/other/other/package-ype/getPackages/").then((
						res) => {
						//console.log("成功")
						this.Packages = res.data.data.list
					})
					.catch((error) => {
						console.log(error);
					});
			},
			change(index) {
				this.index = index
				this.packageId = this.Packages[this.index].id
				console.log(this.packageId)
				this.getPackagesList();

			},
		}
	}
</script>

<style>

</style>
